﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bluyel.Core;

namespace Bluyel_Samples_VS10
{
    /// <summary>
    /// Code samples to see how to create data Values typeof basic types:
    ///  int, double, string, bool.
    /// 
    /// To create data, you need to define built-in types.
    /// Its a way to control how type of data you can create in the application.
    /// 
    /// If you define all built-in types, you can create all type of data.
    /// </summary>
    public class Sample_DVal_Basic
    {
        //---------------------------------------------------------------------
        /// <summary>
        /// </summary>
        public void CreateStringValueHello()
        {
            Console.WriteLine("\n----Create a String value 'hello':\n");

            // create the core and define all built-in types
            BluyelCore core = new BluyelCore();
            core.TypeBuilder.DefineAllTypes();

            // Create a string value, set with 'hello'
            DValString dvString = core.DataBuilder.CreateDValString("hello");
            IType type = core.TypeFinder.GetTypeOfDVal(dvString);

            Console.WriteLine("String value: " + dvString.GetValue());
            Console.WriteLine("Type is: " + type.Name);
        }

        //---------------------------------------------------------------------
        /// <summary>
        /// </summary>
        public void CreateIntValue12()
        {
            Console.WriteLine("\n----Create an Int value:\n");

            // create the core and define all built-in types
            BluyelCore core = new BluyelCore();
            core.TypeBuilder.DefineAllTypes();

            // Create an int value
            DValInt dvInt = core.DataBuilder.CreateDValInt(12);
            IType type = core.TypeFinder.GetTypeOfDVal(dvInt);

            Console.WriteLine("Value: " + dvInt.GetValue());
            Console.WriteLine("Type is: " + type.Name);

            bool res = core.TypeFinder.IsTypeInt(dvInt);
            Console.WriteLine("Is Type Int? " + res);

            res = core.TypeFinder.IsTypeString(dvInt);
            Console.WriteLine("Is Type String? " + res);
        }
    }
}
